package com.yonyou.pmclouds.safeinspection.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;
import com.yonyou.pmclouds.inspectitem.rmiitf.InspectItemService;
import com.yonyou.pmclouds.safeinspection.entity.SafeInspectionVO;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 徐老板
 * @date 2020/4/21   22:58
 */
@Component
public class UpdateInspectItemProcess implements SingleProcessor<SafeInspectionVO> {
    //这个是操作检查标准的类 头一次用
    @Resource
    private InspectItemService inspectItemService;


    @Override
    public void process(SafeInspectionVO vo, SafeInspectionVO orig) throws BusinessException {
        if (vo!=null ){
            InspectItemVO[] inspectItemVOS = vo.getInspectItemVOS();
            if (ArrayUtils.isEmpty(inspectItemVOS)){
                return;
            }
            //这里要分表 所以两个关联的主键要重新设置一下
            for (InspectItemVO inspectItemVO : inspectItemVOS) {
                inspectItemVO.setPk_project(vo.getPk_project());
                inspectItemVO.setPk_bill(vo.getPk_safeinspection());
            }

            inspectItemService.update(inspectItemVOS, vo);

        }
    }
}
